#ifndef METANET_SERVER_H
#define METANET_SERVER_H

#include <stdint.h>
#include <stdlib.h>

struct metanet_context;
struct metanet_message;
struct metanet_message_queue;

struct metanet_context *metanet_context_new(const char *name, const char *param);
void metanet_context_grab(struct metanet_context *ctx);
void metanet_context_reserve(struct metanet_context *ctx);
struct metanet_context *metanet_context_release(struct metanet_context *ctx);
uint32_t metanet_context_handle(struct metanet_context *ctx);
int metanet_context_push(uint32_t handle, struct metanet_message *msg);
void metanet_context_send(struct metanet_context *ctx, void *msg, size_t sz, uint32_t source, int type, int session);
int metanet_context_newsession(struct metanet_context *ctx);

struct metanet_message_queue *metanet_context_message_dispatch(struct metanet_message_queue *mq, int weight);
void metanet_context_message_dispatchall(struct metanet_context *ctx);

void metanet_globalinit(void);
void metanet_globalexit(void);

#endif // !METANET_SERVER_H